import axios from "./axios";

// 登录页的接口请求
// 用户登录接口
export function loginapi(data: {
    loginname: string,
    password: string
}) {
    return axios({
        url: '/user/login',
        method: 'post',
        data
    })
}

// 注册
export function Register(data: {
    tel:string
}) {
    return axios({
        url: '/user/docheckphone',
        method: 'post',
        data
    })
}

// 验证码
export function Code(data:{tel:string}) {
    return axios({
        url: '/user/dosendmsgcode',
        method: 'post',
        data
    })
}


// 验证
export function Verify(data: {
    tel:string,
    telcode:string
}) {
    return axios({
        url: '/user/docheckcode',
        method: 'post',
        data
    })
}


// 注册成功
export function Succeed(data: {
    tel:string,
    password:string
}) {
    return axios({
        url: '/user/dofinishregister',
        method: 'post',
        data
    })
}


// 轮播
export function Swipe(data:{
    id:number
}){
    return axios({
        url:'/banner/list?id=123',
        method:'get',
        data
    })
}

// 秒杀

export function MiaoS(data:{
    count:number
}){
    return axios({
        url:'/pro/seckilllist?count=1',
        method:'get',
        data
    })
}

// list列表

export function ListCount(data:{
    count:number,
    limitNum:number
}){
    return axios({
        url:'/pro/list?count='+data.count,
        method:'get',
        data
    })
}

// 详情页
export function Details(data:{
    proid:string
}){
    return axios({
        url:'/pro/detail/'+data.proid,
        method:'get',
        params:data
    })
}


// 地址
export function Address(data:{
    userid:string
}){
    return axios({
        url:'/address/list',
        method:'get',
        params:data
    })
}

// 购物车列表
export function Cart(data:{
    userid:string
}){
    return axios({
        url:"/cart/list",
        method:'post',
        data
    })
}

// 购物车可能你还想要
export function CartMay(data:{
    count:number
}){
    return axios({
        url:'/pro/recommendlist?count='+data.count,
        method:'get',
        data
    })
}

// 添加购物车
export function CartAdd(data:{
    userid:string,
    proid:string,
    num:string
}){
    return axios({
        url:'/cart/add',
        method:'post',
        data
    })
}


// 删除购物车
export function CartDel(data:{
    cartid:string,
}){
    return axios({
        url:'/cart/remove',
        method:'post',
        data
    })
}


// 添加地址
export function Addr(data:{
    userid:string,
    name:string,
    tel:string,
    province:string,
    city:string
    county:string
    addressDetail:string
    isDefault:boolean
}){
    return axios({
        url:'/address/add',
        method:'post',
        data
    })
}














